<?php
/**
**百度直达号 商品校验接口
**2015-11-06 pm 16:00
**User by PZP
**/
$id = $_REQUEST['id'];
if(!$id)  exit('{"code":"1","error_msg":"请传参"}');


include('/var/www/html/new/d/module/api/function.class.php');
include('/var/www/html/new/d/module/api/bd_zhidahao/baidu_zdh.class.php');
if (!class_exists("go_sql")){
	include("/var/www/html/new/conf/le.je");
	$le=new go_sql();
	$le->connect();
}

$BD_zdh = new BD_zdh();
$PFT_infunction = new AllFunction();

$tids =  explode("|",$id);
$aid = $tids[0];
$lid = $tids[1];
$tid = $tids[2] + 0;

$sel_pid = "select t.pid,t.tprice,p.p_status from uu_products p left join uu_jq_ticket t on t.pid = p.id where t.id=$tid limit 1";
$GLOBALS['le']->query($sel_pid);
if(!$GLOBALS['le']->fetch_assoc())  exit('{"code":"1","error_msg":"无此商品"}');
$pid = $GLOBALS['le']->f('pid');
$tprice = $GLOBALS['le']->f('tprice');
$p_status = $GLOBALS['le']->f('p_status');

$bd_account = '504025';
$bd_ID = 22196;
	
//零售价
$sellPrice_ldata = $PFT_infunction->Dynamic_Price_And_Storage($bd_account,$pid,date('Y-m-d'),1,10),0,$aid);
if($sellPrice_ldata == 105 || $sellPrice_ldata == 1065)  exit('{"code":"1","error_msg":"无此当前时间的价格"}');
$sellPrice_ldata_xml =simpleXML_load_string($sellPrice_ldata);
$sellPrice = (string)$sellPrice_ldata_xml->Rec->UUsprice / 100;
$stock = (int)$lsprice_xml->Rec->UUstorage == -1 ? 1000 : (int)$lsprice_xml->Rec->UUstorage;
if($p_status == 0 || $p_status == 2 || $p_status == 3 || $p_status == 4 || $p_status == 5 )
		$publish_status = 1;
else	$publish_status = 0; 

$response = '{"code":"0","storage":"'.$stock.'","publish_status":"'.$publish_status.'","price":"'.$sellPrice.'"}';

$BD_zdh->logfile(json_encode($_REQUEST).'|'.$response,'bdzdh_get_data');

exit($response);

?>